package com.htgd.gardenexpo.controller;


import com.htgd.gardenexpo.dto.GeConTheaterMovieDTO;
import com.htgd.gardenexpo.entity.CommonResult;
import com.htgd.gardenexpo.entity.GeConTheaterPlan;
import com.htgd.gardenexpo.entity.GeConTheaterPlanReserve;
import com.htgd.gardenexpo.service.IGeConTheaterPlanReserveService;
import com.htgd.gardenexpo.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 剧场预约 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-04-17
 */
@RestController
@RequestMapping("/api/theaterPlanReserve")
@Api( tags = "剧场预约")
@Slf4j
public class GeConTheaterPlanReserveController {

    @Autowired
    private IGeConTheaterPlanReserveService geConTheaterPlanReserveService;

    @PostMapping(value = "/add")
    @ApiOperation("添加")
    public CommonResult add(@RequestBody GeConTheaterPlanReserve geConTheaterPlanReserve, HttpServletRequest request) {
        String accessToken = request.getHeader("Access_token");
        String openId = TokenUtil.getUsernameFromToken(accessToken);
        log.info("剧场预约-添加：{},{}",geConTheaterPlanReserve,openId);
        return geConTheaterPlanReserveService.add(geConTheaterPlanReserve,openId);
    }

    @GetMapping(value = "/getMyRecord")
    @ApiOperation("我的预约记录")
    public CommonResult MyRecord(@RequestParam(defaultValue = "1") Integer pageNum,
                                 @RequestParam(defaultValue = "10") Integer pageSize,
                                 HttpServletRequest request) {
        String accessToken = request.getHeader("Access_token");
        String openId = TokenUtil.getUsernameFromToken(accessToken);
        log.info("剧场预约-我的预约记录：{},{},{}",openId,pageNum,pageSize);
        return geConTheaterPlanReserveService.getMyRecord(openId,pageNum,pageSize);
    }

}
